Imports System.Data.SqlClient


Public Class sqlhelper

    Private Shared strConnectionString As String = "Data Source=139.71.180.72\solar_sqldb;Initial Catalog=SOLARKB;User Id=solaruser;Password=solar;"

    Public Shared Function InsertKB(ByVal args() As String) As Integer
        Dim objconn As New SqlConnection(strConnectionString)
        objconn.Open()

        Dim objcommand As New SqlCommand
        objcommand.Connection = objconn
        objcommand.CommandType = CommandType.StoredProcedure
        objcommand.CommandText = "usp_InsertKB"

        objcommand.Parameters.AddWithValue("@ErrorType", args(0))
        objcommand.Parameters.AddWithValue("@ErrorDescription", args(1))
        objcommand.Parameters.AddWithValue("@ErrorInformation", args(2))
        objcommand.Parameters.AddWithValue("@Resolution", args(3))
        objcommand.Parameters.AddWithValue("@RootCause", args(4))

        objcommand.CommandTimeout = 90000

        objcommand.ExecuteScalar()


    End Function

    Public Shared Function GetKbInfo(ByVal strSearch As String) As SqlDataReader
        Dim objconn As New SqlConnection(strConnectionString)
        objconn.Open()

        Dim objcommand As New SqlCommand
        objcommand.Connection = objconn
        objcommand.CommandType = CommandType.StoredProcedure
        objcommand.CommandText = "usp_SearchKb"

        objcommand.Parameters.AddWithValue("@parm1", strSearch)

        objcommand.CommandTimeout = 90000


        Dim objreader As SqlDataReader = objcommand.ExecuteReader

        Return objreader

    End Function


    Public Shared Function GetKBDetails(ByVal strSearch As String) As DataSet
        Dim objconn As New SqlConnection(strConnectionString)
        objconn.Open()

        Dim objcommand As New SqlCommand
        objcommand.Connection = objconn
        objcommand.CommandType = CommandType.StoredProcedure
        objcommand.CommandText = "usp_Getkbdetails"

        objcommand.CommandTimeout = 90000


        Dim objAdapter As New SqlDataAdapter(objcommand)
        Dim ds As New DataSet
        objAdapter.Fill(ds)
        Return ds

    End Function
End Class
